<?php

$api = app('Dingo\Api\Routing\Router');


$api->version('v1', ['middleware' => 'api.throttle', 'limit' => 60, 'expires' => 1], function($api) {
    //需要登录的路由
    $api->group(['prefix' => 'auth'], function($api) {
        //注册
        $api->post('register',[\App\Http\Controllers\Auth\RegisterController::class,'store']);
        //登录
        $api->post('login',[\App\Http\Controllers\Auth\LoginController::class,'login']);

        //需要登录的路由
        $api->group(['middleware' => 'api.auth'], function($api) {
            //获取登录用户信息
            $api->get('me',[\App\Http\Controllers\Auth\LoginController::class,'me']);
            //退出登录
            $api->post('logout',[\App\Http\Controllers\Auth\LoginController::class,'logout']);
            //刷新token
            $api->post('refresh',[\App\Http\Controllers\Auth\LoginController::class,'refresh']);
            //修改密码
            $api->patch('password/update',[\App\Http\Controllers\Auth\PasswordController::class,'updatePassword']);
            //发送邮件验证码
            $api->post('email/code',[\App\Http\Controllers\Auth\BindController::class,'emailCode']);
            //更新邮箱
            $api->patch('email/update',[\App\Http\Controllers\Auth\BindController::class,'updateEmail']);
            //发送手机验证码
            $api->post('phone/code',[\App\Http\Controllers\Auth\BindController::class,'phoneCode']);
            //更新手机号码
            $api->patch('phone/update',[\App\Http\Controllers\Auth\BindController::class,'updatePhone']);
        });
    });
});

